<?php

class Admin_Search_Prov extends Controller
{
	var $data=array();
	
	public function __construct()
	{
		parent::Controller();
        include("password_protect.php");
		$this->load->model('Admin_Input_Model');
		$this->load->model('Admin_Quotation_Model');

		$this->data['warning']="";
		$this->data['success']="";
		$this->data['search']="";
		$this->data['search_province']="";


	}
	
	function index()
	{
		if($this->input->post('search_province'))
		{
			$this->data['search_province']=trim($this->input->post('search_province_state'));
			$this->search_prov($this->data['search_province']);
		}
		else
			$this->load->view("admin_search_prov",$this->data);

	}
	
	function search_prov($prov)
	{
		$this->data['search_province_list']=$this->Admin_Input_Model->province_state_list($prov);

		if(count($this->data['search_province_list'])==0)
		{
			$this->data['warning']="No province with name \"".$prov."\" was found.";
		}

		$this->load->view("admin_search_prov",$this->data);
	
	}
	
	function delete_province($id, $prov_name)
	{
	//	$this->data['hidden_province_id']=$this->input->post('hidden_province_id');
		
		if($id>=0)
		{
			$this->Admin_Input_Model->delete_province($id);
			$this->data['success']="Province/State \"".$prov_name."\"has been deleted.";
		}
		else
			echo $id;

		$this->data['search_province']=trim($this->input->post('search_province_state'));
		$this->search_prov($this->data['search_province']);
	}


}
